package com.mazaiting.scheduler.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mazaiting.scheduler.domain.entity.SysQuartzJob;
import com.mazaiting.scheduler.manager.QuartzManager;
import com.mazaiting.scheduler.mapper.ISysQuartzJobMapper;
import com.mazaiting.scheduler.service.ISysQuartzJobService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * sys_quartz_job 系统定时任务表 服务实现类
 * </p>
 *
 * @author 党海亮
 * @since 2022-04-05
 */
@Service
public class SysQuartzJobServiceImpl extends ServiceImpl<ISysQuartzJobMapper, SysQuartzJob> implements ISysQuartzJobService {

    /**
     * 定时任务管理
     */
    @Resource
    private QuartzManager quartzManager;

    @Override
    public List<SysQuartzJob> queryByIsPause(boolean isPause) {
        return lambdaQuery().eq(SysQuartzJob::getPause, false).list();
    }

    @Override
    public void execution(SysQuartzJob sysQuartzJob) {
        quartzManager.runJobNow(sysQuartzJob);
    }
}
